Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@travetto/yaml

Package Overview
Dependencies
Maintainers
0
Versions
160
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@travetto/yaml

Simple YAML support, provides only clean subset of yaml

  • 4.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
51
increased by45.71%
Maintainers
0
Weekly downloads
 
Created
Source

YAML

Simple YAML support, provides only clean subset of yaml

Install: @travetto/yaml

npm install @travetto/yaml

# or

yarn add @travetto/yaml

In the desire to provide a minimal footprint, the framework provides a minimal YAML parser/serializer to handle standard configuration structure.

YamlUtil is the main access point for this module, and will expose two method, parse and serialize.

Code: Simple YAML Parsing

import { YamlUtil } from '@travetto/yaml';

export function main(): void {
  const obj = YamlUtil.parse(`
  name: Source
  age: 20
  fields:
    sub: 
      - a
      - b 
      - c
    sub2: [1,2,3]
    sub3: {"k":5, "v":20}
  `);

  console.log(JSON.stringify(obj, null, 2));
}

Terminal: Simple YAML Parsing

$ trv main doc/parse.ts

{
  "name": "Source",
  "age": 20,
  "fields": {
    "sub": [
      "a",
      "b",
      "c"
    ],
    "sub2": [
      1,
      2,
      3
    ],
    "sub3": {
      "k": 5,
      "v": 20
    }
  }
}

Code: Simple YAML Serialization

import { YamlUtil } from '@travetto/yaml';

export function main(): void {
  const text = YamlUtil.serialize({
    name: 'Source',
    age: 20,
    fields: {
      sub: [
        'a',
        'b',
        'c'
      ],
      sub2: [1, 2, 3],
      sub3: { k: 5, v: 20 }
    }
  });

  console.log(text);
}

Terminal: Simple YAML Serialization

$ trv main doc/serialize.ts

name: Source
age: 20
fields:
  sub:
    - a
    - b
    - c
  sub2:
    - 1
    - 2
    - 3
  sub3:
    k: 5
    v: 20

Keywords

FAQs

Package last updated on 20 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc